﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents an embedded external application.
    /// </summary>
    /// <remarks>This element only covers the HTML5-standardized version of the
    /// &lt;embed&gt; tag. Earlier nonstandard versions are not
    /// covered.</remarks>
    [Serializable]
    [Standalone]
    public class Embed : Element {
        private int? _height;
        private string _src;
        private string _type;
        private int? _width;

        /// <summary>
        /// Constructs a new instance of an Embed element.
        /// </summary>
        public Embed() { }

        /// <summary>
        /// Constructs a new instance of an Embed element with the given source
        /// URL.
        /// </summary>
        /// <param name="src"></param>
        public Embed(string src) {
            _src = src;
        }

        /// <summary>
        /// Determines the height, in pixels, of the embedded resource.
        /// </summary>
        public int? Height {
            get { return _height; }
            set { _height = value; }
        }

        /// <summary>
        /// Determines the URL of the embedded resource.
        /// </summary>
        public string Src {
            get { return _src; }
            set { _src = value; }
        }

        /// <summary>
        /// Determines the MIME type of the embedded resource.
        /// </summary>
        public string Type {
            get { return _type; }
            set { _type = value; }
        }

        /// <summary>
        /// Determines the width, in pixels, of the embedded resource.
        /// </summary>
        public int? Width {
            get { return _width; }
            set { _width = value; }
        }

        /// <summary>
        /// Gets a formatted string of all local attributes of this element
        /// (not including the base attributes).
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _height, "height");
            AttributeWriter.Write(sb, _src, "src");
            AttributeWriter.Write(sb, _type, "type");
            AttributeWriter.Write(sb, _width, "width");
        }
    }
}
